ifeq ($(LOCAL), 1)
SDCC=/usr/local/bin/sdcc
SDCC_SHARES=/usr/local/share/sdcc
else
SDCC=sdcc
SDCC_SHARES=/usr/share/sdcc
endif

stepper-table.hex: stepper-table.o usart.o
	$(SDCC) -mpic16 -p18f452 -V --debug -Wl-c -Wl-m -L$(SDCC_SHARES)/non-free/lib/pic16 -I. -o stepper-table.hex stepper-table.o usart.o

stepper-table.o: stepper-table.c stepper-table.h 
	$(SDCC) -mpic16 -p18f452 -V --debug  -I$(SDCC_SHARES)/non-free/include/pic16 -I. -c stepper-table.c 

stepper-t3.hex: stepper-t3-float.o usart.o
	$(SDCC) -mpic16 -p18f452 -V --debug -Wl-c -Wl-m -L$(SDCC_SHARES)/non-free/lib/pic16 -I. -o stepper-t3-float.hex stepper-t3-float.o usart.o libm18f.lib

stepper-t3-float.o: stepper-t3-float.c stepper-t3-float.h 
	$(SDCC) -mpic16 -p18f452 -V --debug  -I$(SDCC_SHARES)/non-free/include/pic16 -I. -c stepper-t3-float.c 

stepper.hex: stepper.o usart.o
	$(SDCC) -mpic16 -p18f452 --use-non-free -I. -o stepper.hex stepper.o usart.o

stepper.o: stepper.c stepper.h 
	$(SDCC) -mpic16 -p18f452 --use-non-free -I. -c stepper.c 
usart.o: usart.c usart.h 
	$(SDCC) -mpic16 -p18f452 --use-non-free -I. -c usart.c 
clean:
	rm *.o *.asm *.adb *.cod *.cof *.hex *.lst *.map 
